<?php
/**
 *
 * @author Quentin Laujac, Charles Hurtevent
 *
 */
require_once ("../enums/enums.php");
require_once ("../bean/data/Article.php");
require_once ("../bean/data/Commande.php");
require_once ("../bean/data/Facture.php");
require_once ("../bean/data/Utilisateur.php");
require_once ("../services/ClientService.php");
require_once ("../services/AuthentificationService.php");
require_once ("../services/AdminService.php");


// si le formulaire est envoye
if($_POST) {
	session_start();
	$authentificationService = new AuthentificationService();
	$adminService = new AdminService();
	$clientService = new ClientService();

	$client = $authentificationService->getClientByNumResponsable($_POST['numClient']);
	$listCommande = $clientService->getHistoriqueCommande ( $client );
	$commandeAFaireColis;
	foreach ($listCommande as $commande){
		if($commande->getNumeroCommande() == $_POST['numCommande']){
			$commandeAFaireColis = $commande;
			break;
		}
	}
	$commandeAFaireColis->setColisFait(true);
	$adminService->faireColis($commandeAFaireColis);

	//redirection
	header('Location: ../action/adminCommandeFactureeAction.php');
	exit();
}
